Repository navigation
feat(sdk): DSPX-5640 negotiate DPoP htu style from server advertisement - #441
Draft
dmihalcik-virtru wants to merge 4 commits into
Draft
dmihalcik-virtru wants to merge 4 commits into
dmihalcik-virtru wants to merge 4 commits into
Conversation
The SDK always signed DPoP proofs with the full request URL as htu. The first DPoP servers (service v0.11.x, DSP 2.7.x) compare an RPC's htu against its procedure and reject a full URL, so a new Java client could not talk to an old server. Pick the htu style per server origin, mirroring the Go SDK (sdk/auth/dpop_mode.go): 1. unauthenticated GET /.well-known/opentdf-configuration; a dpop block's rfc9449 is authoritative, else a non-empty top-level dpop_signing_alg_values_supported means RFC 9449 (service v0.18.0+), 2. else RFC 9728 /.well-known/oauth-protected-resource with that key, 3. else legacy. Only definitive answers are cached: a non-5xx answer from the opentdf well-known (a 4xx or an unparseable 200 means not advertised) or an RFC 9728 advertisement. A network error or 5xx on the well-known step uses legacy for that request only, logs a warning, and is retried on the next request. The platform origin is seeded from the bootstrap well-known response when it advertises, so the common case makes no extra requests. Legacy keeps the DPoP Authorization scheme, ath and nonce handling; only the htu changes, to the procedure (/pkg.Service/Method, the last two path segments, dropping any proxy prefix). Non-RPC requests and token endpoint proofs keep the full URI, and non-DPoP Bearer tokens are unaffected. SDKBuilder.dpopMode(AUTO | LEGACY | RFC9449; default AUTO) overrides discovery, matching Go's WithDPoPMode. Verified with mvn -pl sdk -am test (459 tests, 0 failures). DPoPModeTest covers each advertisement source, both, neither, transient failures not being cached, definitive 404 and unparseable answers being cached, bootstrap seeding, the override, and a nonce challenge in each mode. SDKBuilderTest now checks a seeded platform signs the full URL while a KAS with no well-known documents gets the procedure htu. Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Contributor
…indings Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
Contributor
X-Test Results✅ go@main-main |
The KAS, gateway, and IdP can be upgraded or reconfigured independently of a long-lived SDK client, so a discovered DPoP htu style must not be cached for the client's lifetime. Discovered answers (RFC9449 and LEGACY) and positives seeded from the bootstrap configuration now expire after 5 minutes, and the origin is rediscovered on the next request. Expiry compares nanoTime by difference so it tolerates wraparound. Verified: DPoPModeTest (25, incl. 3 new expiry tests using an injected clock that starts near overflow), SDKBuilderTest (12) and TokenSourceTest (22) pass offline with JDK 21. Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com> Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
|
Contributor
X-Test Results✅ java@v0.20.0-main |
The Java and Go SDKs must choose the same htu form for the same server. This brings the Java resolver in line with the Go DPoPTransport: - Query the well-known configuration through the public Connect RPC (WellKnownService/GetWellKnownConfiguration) rather than a GET path. - Only 404/405/501 or a 200 that isn't a JSON object is a final "not published". Any other status (401, 403, 429, 5xx), a network error, timeout, redirect or a body over 1 MiB is inconclusive. Redirects are no longer followed. - Conclude legacy only once the well-known configuration itself answered; RFC 9728 metadata errors no longer block a conclusive answer. - An inconclusive discovery is legacy for 30 s, then retried, instead of re-running discovery on every request. - Concurrent requests share one discovery, run off the caller's thread with a 10 s overall deadline; an interrupted caller fails fast with its interrupt flag kept while discovery finishes and is cached. - A dpop block without a boolean rfc9449 falls back to the algs check. - A nonce retry signs the same htu form as the challenged proof, replacing the header-sniffing isRpc(). - One debug record per discovery instead of a WARN per failed request. The 5-minute TTL on conclusive answers stays; Go does not have it yet. Verified: DPoPModeTest (41), SDKBuilderTest (12), TokenSourceTest (22), DPoPRetryInterceptorTest (10), AuthInterceptorConnectPathTest (2) pass offline on JDK 21. Mutation check: re-enabling redirects or removing the shared discovery fails the redirect, concurrency and interruption tests. Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
Contributor
X-Test Results✅ java@v0.20.0-main |
dmihalcik-virtru
added a commit
to opentdf/web-sdk
that referenced
this pull request
Nov 17, 2026
…usive (DSPX-3397) Reverts the conclusiveness change from 'retry DPoP discovery when the metadata probe is inconclusive'. The Go (opentdf/platform#4322) and Java (opentdf/java-sdk#441) SDKs conclude legacy once the well-known configuration has answered, regardless of the RFC 9728 probe. Requiring both probes made the web SDK rediscover every 30s, indefinitely, against older servers whose /.well-known/oauth-protected-resource is missing CORS headers or answered by a gateway with 401/403. It only helped a server advertising through RFC 9728 alone during a transient failure. The test now pins the shared rule: a definitive well-known absence keeps legacy for the TTL despite a metadata failure, and a well-known failure retries after 30s. README and class docs describe the same rule. Verified: dpop-mode and dpop-providers mocha specs (34 passing); eslint and prettier clean on the changed source and test files. Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Proposed Changes
Fixes DSPX-5640. Part of epic DSPX-5549 (DPoP RFC 9449 migration, step 2.1). The Go equivalent is opentdf/platform#4322 (DSPX-5639); both SDKs follow the same rules.
Problem. The SDK always signs DPoP proofs with the full request URL as
htu. The first DPoP servers (service v0.11.x, shipped in DSP 2.7.x) compare an RPC'shtuagainst its procedure path, so they reject every request from a current Java client.Fix. Pick the
htustyle per server origin from what the server advertises.GET /.well-known/opentdf-configuration: adpopblock'srfc9449is authoritative; otherwise a non-empty top-leveldpop_signing_alg_values_supportedmeans RFC 9449 (service v0.18.0 and later);/.well-known/oauth-protected-resourcewithdpop_signing_alg_values_supported;htu, to the procedure (/pkg.Service/Method, the last two path segments, dropping any proxy prefix). TheDPoPAuthorization scheme,athand nonce handling are unchanged: step-One servers accept theDPoPscheme, andstrict_schemeservers require it. Non-RPC requests and token-endpoint proofs keep the full URI. Plain Bearer tokens are unaffected.SDKBuilder.dpopMode(DPoPMode.AUTO | LEGACY | RFC9449), defaultAUTO. The existing publicTokenSourceconstructor stays fixed to RFC 9449.Testing
mvn -pl sdk -am test: 459 tests, 0 failures, 9 skipped (the existing FIPS and EC skips). This was before the TTL commit. After it,DPoPModeTest,SDKBuilderTestandTokenSourceTestwere re-run and all pass.DPoPModeTest(25 tests): each advertisement source, both, neither; transient failures not cached and rediscovered; definitive 404 and unparseable answers cached; LEGACY, RFC 9449 and seeded entries expiring after the TTL (using an injected clock that wraps); bootstrap seeding; both overrides; proxy-prefix, non-RPC and short-pathhtu; a nonce challenge in each mode.SDKBuilderTestnow runs inAUTO. A seeded platform signs the full URL, while a KAS with no well-known documents gets the procedurehtu, both under theDPoPscheme.Checklist